<?php

class Notes extends CActiveRecord
{
	/**
	 * The followings are the available columns in table 'Notes':
	 * @var integer $id
	 * @var double $pos_x
	 * @var double $pos_y
	 * @var integer $pos_z
	 * @var string $font
	 * @var string $content
	 * @var integer $tab_id
	 * @var string $created
	 */

	/**
	 * Returns the static model of the specified AR class.
	 * @return CActiveRecord the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'Notes';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('pos_x, pos_y, font, content, tab_id', 'required'),
			array('pos_z, tab_id', 'numerical', 'integerOnly'=>true),
			array('pos_x, pos_y', 'numerical'),
			array('font', 'length', 'max'=>32),
			array('content', 'length', 'max'=>256),
			array('created', 'safe'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'Id',
			'pos_x' => 'Pos X',
			'pos_y' => 'Pos Y',
			'pos_z' => 'Pos Z',
			'font' => 'Font',
			'content' => 'Content',
			'tab_id' => 'Tab',
			'created' => 'Created',
		);
	}

        public function beforeSave(){
            parent::beforeSave();
            $this->created = new CDbExpression("NOW()");
            return true;
        }
}